
#include "HelloS.h"

#define ENV CORBA::Environment& unnecessary_with_exceptions

class World_impl : public POA_World
{
    char * hello (ENV);
};

char *
World_impl::hello (ENV)
{
    return CORBA::string_dup("Greetings from C++ World server!!");
}

main (int argc, char** argv)
{
    try {
            // Initialize the ORB
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

            // Get the Root POA
        CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
        PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);

            // Activate POA manager
        PortableServer::POAManager_var mgr = poa->the_POAManager();
        mgr->activate();

            // Create the servant(s)
        World_impl world_servant;

            // Activate object implicitly by calling _this()
        World_var world = world_servant._this();
        
            // Write stringified reference to stdout
        CORBA::String_var str = orb->object_to_string(world);
        cout << str << endl;

            // Accept requests
        orb->run();
    }
    catch (const CORBA::Exception& e)
    {
        const char* err = e._id();
        cerr << "Server caught CORBA exception: " << err << endl;
        return 100;
    }
    return 0;
}

